<template>
  <div>
    <crumbs
      @goBack="
        () => {
          $router.push({ path: '/workshopDemandList' })
        }
      "
      :superiorMenu="['计划管理', '车间物料需求']"
      currentMenu="详情"
    />

    <div>
      <div class="head">
        <div class="box">
          <div class="boxs" v-for="(item, index) in detailList.headData" :key="index">
            <p class="key">{{ item.key }}</p>
            <p class="value">{{ item.value }}</p>
          </div>
        </div>
      </div>
      <div style="height: calc(100vh - 310px); overflow-y: scroll">
        <div class="wrap" v-for="(item, index) in detailList.centerData" :key="index">
          <div class="title">{{ item.title }}</div>
          <div class="box">
            <div class="boxs" v-for="(items, indexs) in item.children" :key="indexs">
              <p class="key">{{ items.key }}</p>
              <p class="value">{{ items.value }}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import crumbs from '@/components/crumbs.vue'
import { getAction } from '@/api/manage'
export default {
  components: { crumbs },
  data() {
    return {
      detailList: {},
    }
  },
  created() {
    getAction('/planmgt/erpProductMaterialRequirement/queryInfo', { id: this.$route.query.id }).then((res) => {
      console.log(res, 'detail')
      if (res.code === 200) {
        let e = res.result
        this.detailList = {
          headData: [
            {
              key: '物料编号',
              value: e.goodsCode || '-',
            },
            {
              key: '物料名称｜规格',
              value: `${e.goodsName || '-'}｜${e.spec || '-'}`,
            },
            {
              key: '需求数量',
              value: e.totalNumText || '-',
            },
            {
              key: '使用日期',
              value: e.useDate || '-',
            },
            // {
            //   key: '建议采购日期',
            //   value: e.suggestPurchaseDate || '-',
            // },
          ],
          centerData: [
            {
              title: '合同信息',
              children: [
                {
                  key: '合同编号',
                  value: e.contractCode || '-',
                },
                {
                  key: '合同名称',
                  value: e.contractName || '-',
                },
                {
                  key: '所属客户',
                  value: e.customerIdText || '-',
                },
                {
                  key: '承诺交期',
                  value: e.promiseDate || '-',
                },
              ],
            },
            {
              title: '生产订单信息',
              children: [
                {
                  key: '生产订单编号',
                  value: e.code || '-',
                },
                {
                  key: '计划生产数量',
                  value: e.planProductNumUnitText || '-',
                },
                {
                  key: '商品编号',
                  value: e.productCode || '-',
                },
                {
                  key: '商品名称｜规格',
                  value: `${e.productName || '-'}｜${e.productSpec || '-'}`,
                },
              ],
            },
          ],
        }
      }
    })
  },
  methods: {},
}
</script>
<style lang="less" scoped>
.wrap {
  background: #fff;
  margin-top: 12px;
  .title {
    font-size: 16px;
    font-weight: bold;
    color: #191f25;
    padding: 15px 20px;
    border-bottom: 1px solid #f5f5f5;
  }
  .box {
    background: #fff;
    border-top: 1px solid #f5f5f5;
    display: flex;
    justify-content: start;
    flex-wrap: wrap;
    padding: 20px;
    .boxs {
      width: 33.8%;
      margin-bottom: 25px;
      p {
        margin-bottom: 8px;
        font-size: 14px;
      }
      .key {
        color: #444;
      }
      .value {
        color: #888;
      }
    }
  }
}
/deep/.thead {
  background: #fafafa !important;
}
.head {
  width: 102%;
  margin-left: -12px;
  .box {
    background: #fff;
    border-top: 1px solid #f5f5f5;
    display: flex;
    justify-content: start;
    flex-wrap: wrap;
    padding: 20px 20px 0 32px;
    .boxs {
      width: 33.3%;
      margin-bottom: 25px;
      p {
        margin-bottom: 8px;
        font-size: 14px;
      }
      .key {
        color: #444;
      }
      .value {
        color: #888;
      }
    }
  }
}
</style>